package com.lswms.modules.lswms.controller.WCS;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.druid.util.StringUtils;
import com.lswms.common.utils.Result;
import com.lswms.modules.lswms.MEGConstant;
import com.lswms.modules.lswms.service.WCS.WCSService;

import io.swagger.annotations.Api;

@RestController
@RequestMapping("lswms/WCS")
@Api(tags="WCS")
public class WCSController {
	@Autowired
	WCSService wcsService; 
	
	@GetMapping("getDDJ")
	public Result getDDJ() {
		List<Map<String, Object>> list = wcsService.getDDJ();
		
		return new Result().ok(list);
	}
	
	@PutMapping("changeDDJStatus")
	public Result changeDDJStatus(@RequestBody Map map) {
	
		try {
			// 效验数据
			// AssertUtils.isArrayEmpty(receiptkey, "receiptkey");
			String msg = wcsService.changeDDJStatus(map);

			if (StringUtils.isEmpty(msg)) {
				return new Result();
			} else {
				return new Result().error(msg);
			}
		} catch (Exception e) {
			e.printStackTrace();
			return new Result().error(MEGConstant.IS_ERROR);
		}
	}
	
	
	@GetMapping("getWCSTask")
	public Result getWCSTask() {
		List<Map<String, Object>> list = wcsService.getWCSTask();
		
		return new Result().ok(list);
	}
	
	@PutMapping("changeWCS")
	public Result changeWCS(@RequestBody Map map) {
	
		try {
			// 效验数据
			// AssertUtils.isArrayEmpty(receiptkey, "receiptkey");
			String msg = wcsService.changeWCS(map);

			if (StringUtils.isEmpty(msg)) {
				return new Result();
			} else {
				return new Result().error(msg);
			}
		} catch (Exception e) {
			e.printStackTrace();
			return new Result().error(MEGConstant.IS_ERROR);
		}
	}
}
